package org.springframework.samples.petclinic.model.administrator;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface AdminRepository extends Repository<Administrator, Integer> {

	//读取管理员放在List中
	@Query("SELECT administrator FROM Administrator administrator ORDER BY administrator.id")
	@Transactional(readOnly = true)//只读
	List<Administrator> findAdministrator();

	@Query("SELECT administrator.password FROM Administrator administrator WHERE administrator.username=:username")
	@Transactional(readOnly = true)//只读
	String findPassword(@Param("username")String username);
}
